<?php

require_once 'Pipes/Config.php';
require_once 'Pipes/View.php';

class Pipes_Generator_Create_ModelList
{
	private $_projectPath = '';
	private $_view = null;

	public function __construct($projectPath) {
		$this->_projectPath = $projectPath;

		$config = new Pipes_Config(array('projects' => array('PipesCore')));
		$this->_view = new Pipes_View($config, 'GeneratorTemplates');
		$this->_view->project = basename($this->_projectPath);
		$this->_view->generatingClass = __CLASS__;
	}
	public function create($name) {
		$this->_view->name = $name;
		$class = "<?php\n" . $this->_view->render('modelList')->toString();

		$fp = fopen("{$this->_projectPath}/Models/{$name}List.php", 'x+');
		fwrite($fp, $class);
		fclose($fp);
	}
}
